/****************************************************************************/
/*                                                                          */
/* This file contains the interface functions                               */
/* you should use for the wet ex 2                                          */ 
/*                                                                          */ 
/****************************************************************************/

/****************************************************************************/
/*                                                                          */ 
/* File Name : library2.h                                                   */ 
/*                                                                          */ 
/****************************************************************************/

#ifndef _234218_WET2_
#define _234218_WET2_


#ifdef __cplusplus
extern "C" {
#endif




/* Return Values
 * ----------------------------------- */
typedef enum {
	SUCCESS = 0,
	FAILURE = -1,
	ALLOCATION_ERROR = -2,
	INVALID_INPUT = -3
} StatusType;



/* Required Interface for the Data Structure
 * -----------------------------------------*/



/* Description:   Insert Description
 * Input:         DS - A pointer to the data structure.
 *                sectionB - A flag representing whether TowersOfHeightBetween() should be supported.
 *                sectionB = true  if the function should be supported,
 *                sectionB = false  otherwise.
 * Output:        None.
 * Return Values: A pointer to a new instance of the data structure - as a void* pointer.
 */
void*       Init(bool sectionB);


/* Description:   Adds a new cube.
 *                If the number of cubes prior to the call to AddCube() was n, the new cube will receive an ID of n.
 *                Note that a cube may be rotated by 90 degrees.
 * Input:         DS - A pointer to the data structure.
 *                height - The height of new cube to be added.
 *                width - The width of new cube to be added.
 * Output:        None.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, cube.height<=0 or cube.width<=0.
 *                FAILURE - In case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  AddCube(void* DS, int height, int width);


/* Description:   Puts the tower containing cube1 on top of the tower containing cube2, if possible.
 *                (That is, if the bottom of the upper tower can be completely located on the bottom tower).
 * Input:         DS - A pointer to the data structure.
 *                cubeUp - The cube ID of a cube which is part of the upper tower, if the towers are put one on top of the other.
 *                cubeDown - The cube ID of a cube which is part of the bottom tower, if the towers are put one on top of the other.
 *
 * Output:        None.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, cubeUp<0 or cubeDown<0
 *                FAILURE - If either cubeUp or cubeDown are not cube IDs appearing in the structure,
 *                if the upper tower cannot be placed on the lower tower
 *                or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  PutOnTop(void* DS, int cubeUp, int cubeDown);


/* Description:   Returns the height of the tower containing the cube.
 * Input:         DS - A pointer to the data structure.
 *                cube - The cube ID of the cube which is part of the tower for which we return the tower height.
 * Output:        height - A pointer containing the address to which the tower height should be written.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, cube<0 or height==NULL.
 *                FAILURE - If cube is not a cube ID appearing in the structure or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  TowerHeight(void* DS, int cube, int* height);


/* Description:   Returns the height from the ground of the bottom face of the requested cube.
 *                For example, if a cube is placed on the floor, its height is 0.
 * Input:         DS - A pointer to the data structure.
 *                cube - The cube ID.
 * Output:        height - A pointer containing the address to which the height of the cube from the ground should be written.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, cube<0 or height==NULL.
 *                FAILURE - If cube is not a cube ID appearing in the structure or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  HeightFromGround(void* DS, int cube, int* height);


/* Description:   Returns the number of lego towers of height h satisfying: min <= h <= max.
 * Input:         DS - A pointer to the data structure.
 *                min - Lower bound of the range [min,max].
 *                max - Upper bound of the range [min,max].
 * Output:        num - A pointer containing the address to which the number of relevant towers should be written.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, min<0, max<0, min>max or num==NULL.
 *                FAILURE - In case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  TowersOfHeightBetween(void* DS, int min, int max, int* num);


/* Description:   Quits and deletes the database.
 *                DS should be set to NULL.
 * Input:         DS - A pointer to the data structure.
 * Output:        None.
 * Return Values: None.
 */
void        Quit(void** DS);



#ifdef __cplusplus
}
#endif

#endif    /*_234218_WET2_ */ 

